package cn.sixmillions.yuqueblog.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * APP信息获取
 *
 * @author sixmillions
 * @date 2022-08-07
 */
@RestController
@RequestMapping("/api/public/app-info")
@Api(value = "APP-INFO", tags = "APP信息")
public class AppInfoController {

    @Autowired
    private Environment environment;

    @GetMapping("/version")
    @ApiOperation(value = "获取版本信息", notes = "返回当前版本/有效环境配置")
    public String getPropertiProperties() {
        return environment.getProperty("app-info.version", "未查询到版本信息") + "/" +
                environment.getProperty("spring.profiles.active", "未查询到激活配置");
    }

    @GetMapping
    @ApiOperation(value = "hello", notes = "返回 Hello")
    public String hello() {
        return "Hello YuQue Blog!";
    }
}